<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>平台商铺权限管理</title>
    <style>
        .layui-width-100{width: 100px !important;}
        .layui-legend-size{font-size:14px !important;}
        .layui-nopadding{padding:0 !important;}
        .layui-nomargin{margin: 0 !important;}
        .layui-bottom{
            border-width: 0 0 1px 0;
            border-style: solid;
            border-color: rgb(226, 226, 226);
        }
        .layui-input{height:30px !important; }
        .layui-top-margin{margin: 2px 0;}
        .layui-left-margin{margin-left: 10px;}
        .layui-table-page {padding: 7px 0px 0px;}

        .a{font-size:14px !important;}
   	</style>
   	<link rel="stylesheet" href="__STATIC__/js/layui-v2.5.5/css/layui.css">
</head>
<body>
<div class="layui-tab" lay-filter="demo-tab">
    <ul class="layui-tab-title">
        <li class="layui-this"><a href="javascript:;">平台商铺权限管理</a></li>
	</ul>
	

</div>

<script src="__TMPL__/public/assets/js/jquery-1.10.2.min.js"></script>
<script src="__STATIC__/js/layui-v2.5.5/layui.all.js"></script>

<script>
 
	var installaa = false;
	$(function(){
		;!function(){
			var layer = layui.layer
			,form = layui.form;
			//安装
			$('.install-btn').on('click',function(){
			
				let id = $(this).data('tag');
				let name = $(this).data('name');
				let version = $(this).data('version');
				let menu_id = $(this).data('menu_id');
				let status = $( this ).data( 'status' );

				let url = "{:url('AppDevelop/install')}?store_id="+id+"&name="+name+"&version="+version+"&menu_id="+menu_id+"&status="+status;
				let urls = "{:url('AppDevelop/installOperate')}?store_id="+id+"&name="+name+"&version="+version+"&menu_id="+menu_id+"&status="+status;

                let title = '模块安装';
                let btn = [ '安装' , '取消' ];

				var yes = function( index ){
					if(installaa == false){
						layer.msg("模块所需内容未正确配置，安装失败" , { icon:2 , title: '错误提示' , btn:['关闭'] , time:3000 } );return false;
					}
					$.post( urls,{} , function ( data ){ 
						let icon  = ( data.code == 200 ) ? 1 : 5 ;
						layer.msg( data.message , { icon : icon } );
						if( icon == 1 ){
							setTimeout( function(){
								layer.close(index);	
								window.location.reload();
								
							} , 1200 );
						}
					});
                }	
                var cancel =function ( index ){
					layer.close( index );
				}
				layeropen ( url , title , btn , ['500px', '355px'] , yes , cancel  );	
			})

			//layer弹出方法
			var layeropen = function( url , title , btn = [] , area = ['500px', '355px'] , yes = null , cancel = null ){
				layer.open({
					type: 2,
					title: title,
					shadeClose: false,
					shade: 0.1,
				    skin: 'layui-layer-fast', //样式类名
					area: area,
					btn:btn,
					fixed:false,
					content: url, //iframe的url
					yes: function (index, layero) {
						yes( index );
					},
					btn2:function(index, layero){
						cancel(index);
					}
				});
			}

			//更新模块 
		    $('.update-btn').on('click',function(){
		    	let id = $(this).data('tag');
		    	let name = $(this).data('name');
		    	let store = $(this).data('store');
		    	let _this = $(this);
		    	let url = "{:url('AppDevelop/updateOperate')}?code="+id+"&store="+store+"&name="+name;
		    	let text = "是否确认更新？";
		    	layer.confirm(text, {icon: 3, title:'提示', btn: ['确认','取消']}, function(index,layero){
					$.post( url , {} , function( data ){
						let icon = ( data.code == 200 )  ? 1 : 5 ; 
			    		if( data.code == 200 ){
		
			    			layer.msg( data.message , { time:1200 , icon:icon } );
			    		}else{   
			    			layer.msg( data.message , { time:1200 , icon:icon } );
			    		}
			    	} );
					layer.closeAll();
		        },function(index){
		            // alert('取消');
		        });


		    	
		    });
		    
		}();
	})

	//卸载
	$('.uninstall-btn').on('click',function(){
     	var text = "请备份好数据再卸载！确定要卸载此模块吗？";
	  	let id = $(this).data('tag');
	  	let name = $(this).data('name');
	  	let status = $(this).data('status');
	  	let url = "{:url('AppDevelop/unInstallOperate')}?store_id="+id+"&name="+name+"&status="+status;

	  	layer.confirm(text, {icon: 3, title:'提示', btn: ['卸载','取消']}, function(index,layero){
			$.post( url ,{} , function ( data ){ 
				let icon = ( data.code == 200 )  ? 1 : 5 ;   
				layer.msg( data.message , { time:1200 , icon:icon },function(){
					window.location.reload();
				});
			}) 
			layer.closeAll();
        },function(index){
            // alert('取消');
        });
	})


	</script>


</body>
</html>